<template>
  <div class="block text-center" style="height: auto">
    <span class="demonstration">each carousel-item has a different height</span>
    <el-carousel height="auto" autoplay v-if="ImgData !== null">
      <el-carousel-item style="height: 940px" v-for="(item, index) in (ImgData as any)" :key="index">
        <img :src="item.src" alt="Description" class="picture">
      </el-carousel-item>
    </el-carousel>
  </div>
</template>



<script lang="ts">
import { getImg } from '@/api/api';


export default defineComponent({
  components: {

  },
  setup () {
    const data = reactive({
      ImgData: ref(null)
    })
   



    getImg('').then((res: any) => {
      data.ImgData = res._rawValue.title
      console.log(res);
      
    }).catch((err: any) => {
      console.log(err, '请求失败')
    })
    




  
    return {
      ...toRefs(data),
      
    }
  }
})


</script>

<style scoped>

.carousel-item {
  color: #475669;
  opacity: 0.75;
  margin: 0;
  text-align: center;
}

.el-carousel__item h3 {
  color: #475669;
  opacity: 0.75;
  display: flex;
  align-items: center;
  margin: 0;
  text-align: center;
  height: 100%;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}

.picture{
  height: 100%; /* 确保高度自适应，以保持宽高比例 */
  width: 100%; /* 确保宽度自适应，以保持宽高比例 */
  object-fit: cover;
}
</style>
